package com.example.hadoop.rpc.client;

import com.example.hadoop.rpc.ClientNameNodeProtocol;
import com.example.hadoop.rpc.service.ILoginService;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ipc.RPC;

import java.io.IOException;
import java.net.InetSocketAddress;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: Brian
 * @Date: 2020/04/19/21:07
 * @Description: Hadoop RPC client
 */
public class RpcClient {
    public static void main(String[] args) throws Exception {
        ClientNameNodeProtocol nameNode = RPC.getProxy(ClientNameNodeProtocol.class, ClientNameNodeProtocol.versionID, new InetSocketAddress("localhost", 8888), new Configuration());
        String metaData = nameNode.getMetaData("/data/bbb.avi");
        System.out.println("Meta data: " + metaData);

        ILoginService loginService = RPC.getProxy(ILoginService.class, ILoginService.versionID, new InetSocketAddress("localhost", 8888), new Configuration());
        String loginResponse = loginService.login("Brian", "123456");
        System.out.println(loginResponse);

    }
}
